package com.lb.sql;

import java.util.Date;

/**
 * @Author: zhangjun
 * @Date: 2020/7/24 17:12
 * @Description:
 */
public class Test {
    public static void main(String[] args) {
        /*SqlHandle sqlHandle = SqlHandle.getInstance("select * from test t");
        sqlHandle.addSql(" left join user b on b.tid = t.id");
        sqlHandle.addCondition(Condition.eq("t.cwName", "jack"));
        sqlHandle.addCondition(Condition.eq("t.id", 50001));
        System.out.println(sqlHandle.getSql());*/

        /*StringBuilder planSql = new StringBuilder();
        String currentDate = DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss");
        planSql.append("select a.*, b.name AS brand, c.name AS goodsCategory from mfrs_cst_prdPlan a");
        planSql.append(" LEFT JOIN pms_bd_gds_brand b ON a.pmsBdGdsBrandId = b.id");
        planSql.append(" LEFT JOIN pms_bd_category c ON a.pmsBdCategoryId = c.id");
        planSql.append(" where 1=1 and a.isDeleted = 0");
        planSql.append(" and (a.prdStartTime > '" + currentDate + "'");  //未开始 计划
        planSql.append(" or a.prdStartTime < '" + currentDate + "' and a.prdEndTime > '" + currentDate + "')");  //进行中 计划*/

        SqlHandle sqlHandle = SqlHandle.getInstance("select a.*, b.name AS brand, c.name AS goodsCategory from mfrs_cst_prdPlan a","a");
        sqlHandle.addSql("LEFT JOIN pms_bd_gds_brand b ON a.pmsBdGdsBrandId = b.id");
        sqlHandle.addSql("LEFT JOIN pms_bd_category c ON a.pmsBdCategoryId = c.id");
        sqlHandle.addCondition(Condition.lessThan("a.prdStartTime","2020-07-04 10:10:00"));
        System.out.println(sqlHandle.getSql());
    }
}
